<!--评价下级-->
<template>
  <div>
    <el-form :inline="true" :model="dataForm" @keyup.enter.native="search()">
<!--      <el-form-item label="标签">-->
<!--        <el-select v-model="dataForm.tagId" placeholder="全部">-->
<!--          <el-option-->
<!--            v-for="item in options"-->
<!--            :key="item.val"-->
<!--            :label="item.label"-->
<!--            :value="item.val"-->
<!--          ></el-option>-->
<!--        </el-select>-->
<!--      </el-form-item>-->
      <el-form-item label="评价下级状态">
        <el-select v-model="dataForm.avgWholeScore" placeholder="全部">
          <el-option
            v-for="item in evaluationResult"
            :key="item.val"
            :label="item.label"
            :value="item.val"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-input v-model="dataForm.nickname" placeholder="昵称" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-input v-model="dataForm.phone" placeholder="手机号" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="search()">查询</el-button>
        <el-button type="primary" @click="goBack()">返回</el-button>
      </el-form-item>
    </el-form>
    <!--    列表-->
    <el-table :data="dataList" border v-loading="dataListLoading" style="width: 100%;">
      <!--<el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>-->
      <el-table-column prop="nickname" header-align="center" align="center" label="昵称"></el-table-column>
      <el-table-column prop="coverUrl" header-align="center" align="center" label="头像">
        <template slot-scope="scope">
          <img :src="scope.row.avatar" style="width: 40px;height: 40px;" />
        </template>
      </el-table-column>
      <el-table-column prop="phone" header-align="center" align="center" label="手机号"></el-table-column>
      <el-table-column prop="userGrade" header-align="center" align="center" label="会员身份">
        <template slot-scope="scope">
          {{scope.row.userGrade==1 ?'会员':''}}
          {{scope.row.userGrade==2 ?'经理':''}}
          {{scope.row.userGrade==3 ?'总监':''}}
        </template>
      </el-table-column>
      <el-table-column prop="tagName" header-align="center" align="center" label="标签">
        <template slot-scope="scope">
          <span>{{ scope.row.tagName === null ? '-' : scope.row.tagName}}</span>
        </template>
      </el-table-column>
      <el-table-column prop="superiorEvaluationScore" header-align="center" align="center" label="评价下级状态">
        <template slot-scope="scope">
          <span style="color: #aa1111">{{ parseInt(scope.row.superiorEvaluationScore) === 0  ? '未评' :"" }}</span>
          <span>{{ parseInt(scope.row.superiorEvaluationScore) === 0  ? '' : scope.row.superiorEvaluationScore }}</span>
        </template>
      </el-table-column>
      <el-table-column header-align="center" align="center" label="操作">
        <template slot-scope="scope">
          <el-button v-if="parseInt(scope.row.superiorIsDefaultScore) === 1 " type="text" size="small" @click="evaluationAction(scope.row.valueId, 0)">评价</el-button>
          <el-button v-if="parseInt(scope.row.superiorIsDefaultScore) === 0" type="text" size="small" @click="resultAction(scope.row.valueId, 1)">查看</el-button>
          <el-button v-if="parseInt(scope.row.superiorIsDefaultScore) === 0" type="text" size="small" @click="changeAction(scope.row.valueId, 1)">修改</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="sizeChangeHandle"
      @current-change="currentChangeHandle"
      :current-page="pageIndex"
      :page-sizes="[10, 20, 50, 100]"
      :page-size="pageSize"
      :total="totalPage"
      layout="total, sizes, prev, pager, next, jumper"
    ></el-pagination>

    <examine-evaluate-under ref="examinevaluate" @refreshDataList="getDataList"></examine-evaluate-under>
    <examine-evaluate-show ref="examinevaluateshow"></examine-evaluate-show>

  </div>
</template>

<script>
    import ExamineEvaluateUnder from "./examinevaluateunder";
    import ExamineEvaluateShow from "./examinevaluateshow";
    export default {
        name: "valueManageEvaluationSubList",

        components: {ExamineEvaluateUnder, ExamineEvaluateShow},
        data() {
            return {
                options: [
                    {
                        val: null,
                        label: "全部"
                    },
                ],

                //评价结果
                evaluationResult: [
                    {
                        val: "3",
                        label: "全部"
                    },
                    {
                        val: "1",
                        label: "已评价"
                    },
                    {
                        val: "0",
                        label: "未评价"
                    }
                ],

                dataForm: {
                    userGrade:"", //   userGrade:会员身份
                    avgWholeScore:"3",  //     avgWholeScore:0未评、1已评 3全部
                    key: "",
                    rember: "",
                    uid: "",
                    phone: "",
                    nickname: "",
                    title: "",
                },

                userId: "",
                dataList: [],
                pageIndex: 1,
                pageSize: 10,
                totalPage: 0,
                dataListLoading: false,
                addOrUpdateVisible: false,
            };
        },
        mounted() {
            this.init()
        },
        methods: {

            init () {
                this.getDataList();
                // this.getTagNameDataList();
            },

            goBack () {
                this.$emit('goback')
            },

            search(){
                this.pageIndex = 1;
                this.getDataList();
            },
            // 获取数据列表
            getDataList() {
                this.dataListLoading = true;
                let obj = {
                    page: this.pageIndex,
                    limit: this.pageSize
                };

                if (this.dataForm.tagId) {
                    obj.tagId = this.dataForm.tagId;
                }

                if (this.dataForm.avgWholeScore) {
                    obj.isEvaluated = this.dataForm.avgWholeScore;
                }
                if (this.dataForm.nickname) {
                    obj.nickname = this.dataForm.nickname;
                }
                if (this.dataForm.phone) {
                    obj.phone = this.dataForm.phone;
                }

                this.$http({
                    url: this.$http.adornUrl("/value/valuecommentinfo/evaluateSubordinateList"),
                    method: "get",
                    params: this.$http.adornParams(obj)
                }).then(({ data }) => {
                    if (data && data.code === 0) {
                        this.dataList = data.page.list;
                        this.totalPage = data.page.totalCount;

                    } else {
                        this.dataList = [];
                        this.totalPage = 0;
                    }
                    this.dataListLoading = false;
                });
            },

            // 获取数据列表
            // getTagNameDataList() {
            //     let obj = {
            //         page: this.pageIndex,
            //         limit: 100
            //     };
            //
            //     this.$http({
            //         url: this.$http.adornUrl("/value/tag/list"),
            //         method: "get",
            //         params: this.$http.adornParams(obj)
            //     }).then(({ data }) => {
            //         if (data && data.code === 0) {
            //             if (data.page.list) {
            //                 let tagNameList = []
            //                 data.page.list.map(item =>{
            //                     let tagNameObject = {
            //                         val:item.id,
            //                         label:item.tagName
            //                     }
            //                     tagNameList.push(tagNameObject)
            //                 })
            //                 tagNameList.unshift({val:null,label:"全部"})
            //                 this.options = tagNameList
            //             }
            //         }
            //     });
            // },

            // 评价
            evaluationAction(id, ischange){
              this.$nextTick(()=> {
                this.$refs.examinevaluate.init(id, ischange)
              })
            },

            // 查看
            resultAction(id, ischange){
              this.$nextTick(()=> {
                this.$refs.examinevaluateshow.init(id, ischange)
              })
            },

            // 修改
            changeAction(id, ischange){
              this.$nextTick(()=> {
                this.$refs.examinevaluate.init(id, ischange)
              })
            },

            // 每页数
            sizeChangeHandle(val) {
                this.pageSize = val;
                this.pageIndex = 1;
                this.getDataList();
            },
            // 当前页
            currentChangeHandle(val) {
                this.pageIndex = val;
                this.getDataList();
            },


        }
    }
</script>

<style scoped>

</style>
